home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0429.dms / q0429.adf / libshade / lex.l < prev    next >
Text File  |  1992-05-20  |  5KB  |  217 lines

  1. /* lex.l                                   */
  2. /* Copyright (C) 1989, 1991, Craig E. Kolb                   */
  3. /* All rights reserved.                               */
  4. /*                                       */
  5. /* This software may be freely copied, modified, and redistributed,       */
  6. /* provided that this copyright notice is preserved on all copies.       */
  7. /*                                       */
  8. /* You may not distribute this software, in whole or in part, as part of   */
  9. /* any commercial product without the express consent of the authors.       */
  10. /*                                        */
  11. /* There is no warranty or other guarantee of fitness of this software       */
  12. /* for any purpose.  It is provided solely "as is".               */
  13. /*                                       */
  14. /* $Id: lex.l,v 4.0.1.3 92/01/14 18:28:38 cek Exp Locker: cek $ */
  15. %{
  16. #include "config.h"
  17. #include "rayshade.h"
  18. #ifdef I_STRING
  19. #include <string.h>
  20. #else
  21. #include <strings.h>
  22. #endif
  23. #include "liblight/light.h"
  24. #include "libsurf/atmosphere.h"
  25. #include "libsurf/surface.h"
  26. #include "libtext/texture.h"
  27. #include "libobj/geom.h"
  28. #include "symtab.h"
  29. #include "y.tab.h"
  30. extern char *strsave();
  31. %}
  32. alpha    [a-zA-Z]
  33. special    [\.\_-]
  34. digit    [0-9]
  35. exp    [Ee][-+]?{digit}+
  36. string    {alpha}({alpha}|{digit}|{special})*
  37. filename "/"?"/"?(("."|".."|{string})"/")*{string}
  38. %p 9400
  39. %e 1500
  40. %n 600
  41. %%
  42. [ \t\n]            ;
  43. ^#            handlehash();
  44. "/*"            skipcomments();
  45. ambient            return tAMBIENT;
  46. aperture        return tAPERTURE;
  47. applysurf        return tAPPLYSURF;
  48. area            return tAREA;
  49. atmosphere        return tATMOSPHERE;
  50. background        return tBACKGROUND;
  51. blob            return tBLOB;
  52. blotch            return tBLOTCH;
  53. body            return tBODY;
  54. box            return tBOX;
  55. bump            return tBUMP;
  56. checker            return tCHECKER;
  57. cloud            return tCLOUD;
  58. cone            return tCONE;
  59. component        return tCOMPONENT;
  60. contrast        return tCONTRAST;
  61. crop            return tCROP;
  62. cursurf            return tCURSURF;
  63. cutoff            return tCUTOFF;
  64. cylinder        return tCYL;
  65. cylindrical        return tCYLINDRICAL;
  66. define            return tDEFINE;
  67. diffuse            return tDIFFUSE;
  68. difference        return tDIFFERENCE;
  69. directional        return tDIRECTIONAL;
  70. disc            return tDISC;
  71. end            return tEND;
  72. extended        return tEXTENDED;
  73. extinct            return tEXTINCT;
  74. eyep            return tEYEP;
  75. eyesep            return tEYESEP;
  76. filter            return tFILTER;
  77. fbm            return tFBM;
  78. fbmbump            return tFBMBUMP;
  79. focaldist        return tFOCALDIST;
  80. fog            return tFOG;
  81. fogdeck            return tFOGDECK;
  82. fov            return tFOV;
  83. framelength        return tFRAMELENGTH;
  84. frames            return tFRAMES;
  85. gauss            return tGAUSS;
  86. gloss            return tGLOSS;
  87. grid            return tGRID;
  88. heightfield        return tHEIGHTFIELD;
  89. image            return tIMAGE;
  90. index            return tINDEX;
  91. intersect        return tINTERSECT;
  92. jitter            return tJITTER;
  93. light            return tLIGHT;
  94. list            return tLIST;
  95. lookp            return tLOOKP;
  96. map            return tMAP;
  97. marble            return tMARBLE;
  98. maxdepth        return tMAXDEPTH;
  99. mount            return tMOUNT;
  100. mist            return tMIST;
  101. name            return tNAME;
  102. nojitter        return tNOJITTER;
  103. noshadow        return tNOSHADOW;
  104. object            return tOBJECT;
  105. outfile            return tOUTFILE;
  106. plane            return tPLANE;
  107. planar            return tPLANAR;
  108. point            return tPOINT;
  109. poly            return tPOLY;
  110. polygon            return tPOLY;
  111. print            return tPRINT;
  112. quiet            return tQUIET;
  113. range            return tRANGE;
  114. reflect            return tREFLECT;
  115. reflective        return tREFLECT;
  116. report            return tREPORT;
  117. resolution        return tSCREEN; /* A synonym for screen */
  118. rotate            return tROTATE;
  119. sample            return tSAMPLE;
  120. scale            return tSCALE;
  121. screen            return tSCREEN;
  122. shadowtransp        return tSHADOWTRANSP;
  123. shutter            return tSHUTTER;
  124. sky            return tSKY;
  125. smooth            return tSMOOTH;
  126. sphere            return tSPHERE;
  127. spherical        return tSPHERICAL;
  128. specular        return tSPECULAR;
  129. specpow            return tSPECPOW;
  130. spot            return tSPOT;
  131. starttime        return tSTARTTIME;
  132. stripe            return tSTRIPE;
  133. surface            return tSURFACE;
  134. textsurf        return tTEXTSURF;
  135. texture            return tTEXTURE;
  136. tile            return tTILE;
  137. torus            return tTORUS;
  138. transform        return tTRANSFORM;
  139. translate        return tTRANSLATE;
  140. translu            return tTRANSLU;
  141. translucency        return tTRANSLU;
  142. transp            return tTRANSP;
  143. transparent        return tTRANSP;
  144. triangle        return tTRIANGLE;
  145. triangleuv        return tTRIANGLEUV;
  146. union            return tUNION;
  147. up            return tUP;
  148. uv            return tUV;
  149. verbose            return tVERBOSE;
  150. window            return tWINDOW;
  151. windy            return tWINDY;
  152. wood            return tWOOD;
  153. {digit}+ |
  154. {digit}+"."{digit}*({exp})? |
  155. {digit}*"."{digit}+({exp})? |
  156. {digit}+{exp}        {yylval.d = atof(yytext); return tFLOAT;}
  157. {string}        {yylval.c = strsave(yytext); return tSTRING;}
  158. {filename}        {yylval.c = strsave(yytext); return tFILENAME;}
  159. .            return yytext[0];
  160.  
  161. %%
  162. yywrap() {return 1;}
  163. /*
  164.  * Skip over comments.
  165.  */
  166. skipcomments()
  167. {
  168.     char c;
  169.  
  170.     while (1) {
  171.         while (input() != '*')
  172.             ;
  173.         if ((c = input()) == '/')
  174.             return;
  175.         unput(c);
  176.     }
  177. }
  178. /*
  179.  * Deal with ccp-produced lines of the form:
  180.  * # n "filename"
  181.  * and
  182.  * # n
  183.  * Where filename is the name of the file being processed, and n is
  184.  * the current line number in that file.
  185.  */
  186. handlehash()
  187. {
  188.     char buf[BUFSIZ];
  189.     int i;
  190.     extern int yylineno;
  191.     extern char yyfilename[];
  192.  
  193.     /*
  194.      * Read the entire line into buf.
  195.      */
  196.     for (i = 0; (buf[i] = input()) != '\n'; i++)
  197.             ;
  198.     unput(buf[i]);        /* To make sure consecutive # lines work. */
  199.     buf[i] = (char)NULL;    /* Replace newline with NULL. */
  200.  
  201.     /*
  202.      * Complain if the line was not of the form #n "filename"
  203.      */
  204.     if ((i = sscanf(buf,"%d \"%[^\"]s\"", &yylineno, yyfilename)) == 0 &&
  205.         (i = sscanf(buf," line %d \"%[^\"]s\"",&yylineno,yyfilename))==0) {
  206.         RLerror(RL_PANIC, "Unknown '#' control (%s).\n",buf);
  207.         exit(1);
  208.     }
  209.     if (i == 1 && (index(buf,'"') != (char *)NULL)) {
  210.         /*
  211.          * Filename was given as ""
  212.          */
  213.         (void)strcpy(yyfilename, "stdin");
  214.     }
  215.     yylineno--;  /* The newline we unput will increment yylineno */
  216. }
  217.